import React from 'react';
import ReactDOM from 'react-dom';
import dva, { createBrowserHistory } from 'dva';
import createLoading from 'dva-loading';
import forEach from 'lodash/forEach';
import rootRouter from '@/root/rootRouter';
import Root from '@/root/Root';
import modles from '@/root/models';
import locale from '@/shared/services/i18n/locale';
import Globalize from '@/shared/services/i18n/Globalize';
import './index.less';

const history = createBrowserHistory();

locale.initialize();

Globalize.locale = locale.currentLocale;

const app = dva({ history });

forEach(modles, model => app.model(model));

app.router(rootRouter);

app.use(createLoading());

const App = app.start();

ReactDOM.render(
  <Root>
    <App />
  </Root>,
  document.getElementById('root')
);
